Fix non-portability in xentrace
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 28 Feb 2008 10:19:49 +0000 (10:19 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 28 Feb 2008 10:19:49 +0000 (10:19 +0000)
Replace statfs() with the equivalent statvfs(), and correct the block
size multiplier.

Signed-off-by: John Levon <john.levon@sun.com>
tools/xentrace/xentrace.c

index 526a69f73dc7ff1f897152a7b27891c4a79d8dae..aaef3f09fb763eaeef93852e878cb3f2493465fb 100644 (file)
@@ -15,7 +15,6 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/vfs.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -25,6 +24,7 @@
 #include <getopt.h>
 #include <assert.h>
 #include <sys/poll.h>
+#include <sys/statvfs.h>
 
 #include <xen/xen.h>
 #include <xen/trace.h>
@@ -87,7 +87,7 @@ void close_handler(int signal)
 void write_buffer(unsigned int cpu, unsigned char *start, int size,
                int total_size, int outfd)
 {
-    struct statfs stat;
+    struct statvfs stat;
     size_t written = 0;
     
     if ( opts.disk_rsvd != 0 )
@@ -95,13 +95,13 @@ void write_buffer(unsigned int cpu, unsigned char *start, int size,
         unsigned long long freespace;
 
         /* Check that filesystem has enough space. */
-        if ( fstatfs (outfd, &stat) )
+        if ( fstatvfs (outfd, &stat) )
         {
                 fprintf(stderr, "Statfs failed!\n");
                 goto fail;
         }
 
-        freespace = stat.f_bsize * (unsigned long long)stat.f_bfree;
+        freespace = stat.f_frsize * (unsigned long long)stat.f_bfree;
 
         if ( total_size )
             freespace -= total_size;